<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>

<SCRIPT TYPE="text/javascript">
<!--
function message(message) {
	document.getElementById('messagediv').innerHTML = message;
}

function submit() {
	if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
	}
	else {// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	var name = document.getElementById('name').value;
	var email = document.getElementById('email').value;
	var pre = document.getElementById('pre').value;
	var inflation = document.getElementById('inflation').value;
	var url = "upload?name="+name+"&email="+email+"&pre="+pre+"&inflation="+inflation;
	message("Submitting workflow...");
	xmlhttp.open("PUT",url,false);
	xmlhttp.send();
	xmlDoc=xmlhttp.responseXML; 
	
	var html = "<table class='input' id='errors'>"
	if (null == xmlDoc) { 
		message("Workflow submitted OK");
		//window.location.href="index.html";
	} else {
		message("Errors:");
		var x=xmlDoc.getElementsByTagName("error");
		var error;
		for (i=0;i<x.length;i++) { 
			error=x[i].childNodes[0].nodeValue;
			html = html + "<tr><td>" +error + "</td></tr>";
		}
	}
	html = html + "</table>";
	document.getElementById('tablediv').innerHTML = html;
}
//-->
</SCRIPT>

<table class='input'>
<tr><td align="right">Workflow Name:</td><td><input type="text" id="name" size="35" /></td></tr>
<tr><td align="right">Notification E-Mail:</td><td><input type="text" id="email" size="35" /></td></tr>
<tr><td align="right">MCL Pre-Inflation:</td><td><input type="text" id="pre" size="4"/></td></tr>
<tr><td align="right">MCL Inflation:</td><td><input type="text" id="inflation" size="4"/></td></tr>
</table>

<table class='input' width="100%">
<tr>
<th>Reference</th>
<th>Sample</th>
</tr>
<tr>
<td>
<APPLET CODE="jfileupload.upload.client.MApplet.class" JAVA_CODEBASE="./" ARCHIVE="lib/jfileupload.jar,lib/httpimpl.jar,lib/chttpclient.jar,lib/clogging.jar" WIDTH="100%" HEIGHT="200" NAME="fileupload">
<PARAM NAME=CODE VALUE="jfileupload.upload.client.MApplet.class">
<PARAM NAME=CODEBASE VALUE="./">
<PARAM NAME=ARCHIVE VALUE="lib/jfileupload.jar,lib/httpimpl.jar,lib/chttpclient.jar,lib/clogging.jar">
<PARAM NAME=NAME VALUE="fileupload">
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.4">
<PARAM NAME="scriptable" VALUE="true">
<PARAM NAME="url" VALUE="http://localhost:8763/sanger/upload">
<!--  <PARAM NAME="url" VALUE="http://netsoc.com:8763/sanger/upload"> -->
<PARAM NAME="paramfile" VALUE="uploadfile">
<PARAM NAME="param1" VALUE="account">
<PARAM NAME="value1" VALUE=<sec:authentication property="principal.username"/>>
<PARAM NAME="param2" VALUE="type">
<PARAM NAME="value2" VALUE="reference"/>
<PARAM NAME="mode" VALUE="http">'
</APPLET>
</td>
<td>
<APPLET CODE="jfileupload.upload.client.MApplet.class" JAVA_CODEBASE="./" ARCHIVE="lib/jfileupload.jar,lib/httpimpl.jar,lib/chttpclient.jar,lib/clogging.jar" WIDTH="100%" HEIGHT="200" NAME="fileupload">
<PARAM NAME=CODE VALUE="jfileupload.upload.client.MApplet.class">
<PARAM NAME=CODEBASE VALUE="./">
<PARAM NAME=ARCHIVE VALUE="lib/jfileupload.jar,lib/httpimpl.jar,lib/chttpclient.jar,lib/clogging.jar">
<PARAM NAME=NAME VALUE="fileupload">
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.4">
<PARAM NAME="scriptable" VALUE="true">
<PARAM NAME="url" VALUE="http://localhost:8763/sanger/upload">
<!--  <PARAM NAME="url" VALUE="http://netsoc.com:8763/sanger/upload"> -->
<PARAM NAME="paramfile" VALUE="uploadfile">
<PARAM NAME="param1" VALUE="account">
<PARAM NAME="value1" VALUE=<sec:authentication property="principal.username"/>>
<PARAM NAME="param2" VALUE="type">
<PARAM NAME="value2" VALUE="sample"/>
<PARAM NAME="mode" VALUE="http">'
</APPLET>
</td>
</tr>
</table>
&nbsp;
</br>
<button onclick="submit()"><fmt:message key="button.submit"/></button>
<div id="messagediv"/>
<div id="tablediv"/>
